Skip to content

feat: automate upstream patch sync#1

Merged
riderx merged 1 commit into
mainfrom
codex/auto-sync-upstream-patches
May 17, 2026
Merged

feat: automate upstream patch sync#1
riderx merged 1 commit into
mainfrom
codex/auto-sync-upstream-patches

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented May 14, 2026

Summary

  • add a scheduled workflow that scans Capacitor+ sync/upstream-pr-* branches every 6 hours and opens patch catalog PRs
  • add a patch sync runner that filters external Capacitor PRs, checks Capacitor+ branch status, generates package-root patches, and builds compiled artifacts for core/CLI/native bridge patches
  • add a post-merge workflow that can comment quick-patch instructions on upstream Capacitor PRs when a PAT is configured
  • document the recurring sync and manual DX

Validation

  • bun run test
  • bun run lint
  • bun run verify
  • bun run sync:patches -- --capacitor-plus-dir /Users/martindonadieu/Projects/capgo_all/capgo_plugins/capacitor-plus --remote capgo --base-ref capgo/plus --dry-run --no-require-checks --max-build-prs 0
  • bun run sync:patches -- --capacitor-plus-dir /Users/martindonadieu/Projects/capgo_all/capgo_plugins/capacitor-plus --remote capgo --base-ref capgo/plus --pr 7598 --dry-run --no-require-checks --max-build-prs 1
  • bun run sync:patches -- --capacitor-plus-dir /Users/martindonadieu/Projects/capgo_all/capgo_plugins/capacitor-plus --remote capgo --base-ref capgo/plus --pr 6991 --refresh-existing --dry-run --no-require-checks --max-build-prs 1
  • git diff --check

Summary by CodeRabbit

Release Notes

  • New Features

    • Automated upstream patch synchronization workflow running every 6 hours with manual trigger support.
    • Automated pull request commenting for merged upstream patches.
  • Documentation

    • Updated with comprehensive recurring patch automation workflow documentation, including configuration options and manual invocation instructions.
  • Tests

    • Added test suite validating patch synchronization helper functions.
  • Chores

    • Updated build scripts and git configuration.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a6919e9-1af9-400a-b218-c2d114ccb9b6

📥 Commits

Reviewing files that changed from the base of the PR and between 33af6dc and 93e4d86.

📒 Files selected for processing (9)
  • .github/workflows/comment-upstream-patches.yml
  • .github/workflows/sync-upstream-patches.yml
  • .gitignore
  • README.md
  • package.json
  • scripts/capacitor-patch/upstream-sync.mjs
  • scripts/comment-upstream-patches.mjs
  • scripts/sync-upstream-patches.mjs
  • scripts/test-upstream-sync.mjs

📝 Walkthrough

Walkthrough

This PR introduces complete automation infrastructure for synchronizing Capacitor upstream patches. A new library module implements patch detection, generation, and cataloging; two CLI scripts provide entry points for manual/scheduled sync and post-merge commenting; two GitHub Actions workflows orchestrate scheduled and event-driven execution; and supporting tests, documentation, and configuration tie the system together.

Changes

Upstream Patch Synchronization Automation

Layer / File(s) Summary
Core upstream-sync library module
scripts/capacitor-patch/upstream-sync.mjs
Exports constants for Android/iOS and compiled patch targets, plus functions to parse sync branches, build catalog entries with stable IDs, group changed files into patch types, orchestrate patch generation via git worktrees and build steps, post quick-patch comments on upstream PRs, and provide GitHub API and git command infrastructure.
Test suite for upstream-sync helpers
scripts/test-upstream-sync.mjs
Validates branch number parsing, author classification (external vs internal), patch target grouping, catalog entry construction and ID stability, catalog sorting by PR number, and quick-patch comment rendering for single and multiple entries.
Sync CLI entry point
scripts/sync-upstream-patches.mjs
Command-line interface to orchestrate patch sync: accepts --capacitor-plus-dir, --require-checks, --refresh-existing, --dry-run, --max-build-prs, and --pr flags; obtains GitHub token; invokes syncUpstreamPatches; logs generated entries and skipped PRs with reasons.
Comment CLI entry point
scripts/comment-upstream-patches.mjs
Command-line interface to post quick-patch comments on merged patch PRs: parses --base, --head, and --dry-run; obtains GitHub token; invokes commentOnUpstreamPullRequests; reports posted PRs and errors.
GitHub Actions workflows
.github/workflows/sync-upstream-patches.yml, .github/workflows/comment-upstream-patches.yml
sync-upstream-patches.yml runs on schedule (6h) or manual trigger with configurable inputs; checks out repo, mirrors upstream branches, runs sync CLI, formats catalog, runs verification, and opens/updates patch PR. comment-upstream-patches.yml runs on PR close (merged only); posts quick-patch comments on upstream PRs using base/head commit SHAs.
Configuration and documentation
package.json, README.md, .gitignore
package.json adds sync:patches and comment:upstream-patches Bun script targets and extends test:patch script. README.md documents the recurring patch automation workflow, manual run command, and supported options. .gitignore excludes .tmp temporary directories.

Sequence Diagram

sequenceDiagram
  participant Schedule as GitHub Actions Cron
  participant SyncCLI as sync-upstream-patches CLI
  participant SyncLib as syncUpstreamPatches
  participant GitPlatform as GitHub
  participant GitOps as Git/Build
  participant Catalog as patches/catalog.json
  
  Schedule->>SyncCLI: trigger sync workflow with options
  SyncCLI->>SyncLib: invoke with repo/token/flags
  SyncLib->>GitPlatform: list sync/upstream-pr-* branches
  SyncLib->>GitPlatform: fetch PR metadata and check status
  SyncLib->>GitOps: compute changed files vs base
  SyncLib->>GitOps: generate direct patch diffs
  SyncLib->>GitOps: generate compiled patch diffs (worktrees)
  SyncLib->>Catalog: write patches, update entries
  SyncCLI->>Schedule: report generated entries
  Schedule->>GitPlatform: create/update patch PR

  rect rgba(0, 128, 255, 0.5)
  Note over Schedule,Catalog: PR is merged
  end

  GitPlatform-->>Schedule: pull_request closed (merged)
  Schedule->>CommentCLI as comment-upstream-patches CLI: trigger comment workflow
  CommentCLI->>CommentLib as commentOnUpstreamPullRequests: invoke with base/head
  CommentLib->>Catalog: load base catalog (at base SHA)
  CommentLib->>Catalog: load head catalog (at head SHA)
  CommentLib->>GitPlatform: post quick-patch comment on upstream PR
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Patches flow upstream through twisted git trees,
Branching and building with test-happy ease,
Comments arise when the work finds its ground,
Automation dancing—no manual round! 🌿✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/auto-sync-upstream-patches

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

scripts/comment-upstream-patches.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install `@typescript-eslint/eslint-plugin`@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "package.json » @ionic/eslint-config/recommended » ./index".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

scripts/sync-upstream-patches.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install `@typescript-eslint/eslint-plugin`@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "package.json » @ionic/eslint-config/recommended » ./index".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

scripts/capacitor-patch/upstream-sync.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install `@typescript-eslint/eslint-plugin`@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "package.json » @ionic/eslint-config/recommended » ./index".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 1 others

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

Beta npm build

Maintainers can publish this PR to npm for fast testing.

Comment /publish-beta after the PR checks are green.

The workflow will:

  • publish a prerelease package on the beta tag
  • add a pinned pr-1 dist-tag for this exact PR build
  • update this comment with the install command

Security note: beta publish is only enabled for branches inside this repository.

@riderx riderx marked this pull request as ready for review May 17, 2026 08:52
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@riderx riderx merged commit e8453f0 into main May 17, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant